package com.micro.ai.template.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.micro.ai.template.entity.WorkflowDefinition;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 工作流定义Mapper
 *
 * @author micro-ai
 * @since 0.0.1
 */
@Mapper
public interface WorkflowDefinitionMapper extends BaseMapper<WorkflowDefinition> {

    /**
     * 查询所有启用的工作流
     */
    @Select("SELECT * FROM workflow_definitions WHERE enabled = true ORDER BY created_at DESC")
    List<WorkflowDefinition> selectAllEnabled();

    /**
     * 根据创建者查询工作流
     */
    @Select("SELECT * FROM workflow_definitions WHERE created_by = #{createdBy} ORDER BY created_at DESC")
    List<WorkflowDefinition> selectByCreatedBy(@Param("createdBy") String createdBy);
}

